
// plupload 说明文档 http://chaping.github.io/plupload/doc/#plupload_doc7
var uploader1 = new plupload.Uploader({ //实例化一个plupload上传对象
    browse_button: 'file1',
    url: '/file/upload',
    flash_swf_url: 'js/Moxie.swf',
    silverlight_xap_url: 'js/Moxie.xap'
});
uploader1.init(); //初始化

//绑定文件添加进队列事件
uploader1.bind('FilesAdded', function (uploader, files) {
    for (var i = 0, len = files.length; i < len; i++) {
        var file_name = files[i].name; //文件名
        //构造html来更新UI
        var html = '<li id="file-' + files[i].id + '"><p class="file-name">' + file_name + '</p><p class="progress" style="width: 0px;"></p></li>';
        $(html).appendTo('#file-list');
    }
});

//绑定文件上传进度事件
uploader1.bind('UploadProgress', function (uploader, file) {
    $('#file-' + file.id + ' .progress').css('width', file.percent + '%');//控制进度条
});

//上传按钮
$('#uploadFile1').click(function () {
    uploader1.start(); //开始上传
});